-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix suggestions for dotted constant patterns in Color Color case #75373
Fix suggestions for dotted constant patterns in Color Color case #75373
Conversation
src/Workspaces/CSharp/Portable/Recommendations/CSharpRecommendationServiceRunner.cs
Outdated
Show resolved
Hide resolved
var reinterpretedBinding = semanticModel.GetSpeculativeSymbolInfo(identifier.SpanStart, identifier, SpeculativeBindingOption.BindAsTypeOrNamespace); | ||
var reinterpretedSymbol = reinterpretedBinding.GetAnySymbol(); | ||
|
||
// The reinterpretation must be a type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because...?
(this comment explains what the code does, but not why).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an oversight. We also want to allow other kinds of symbols like aliases, namespaces and types. Will update, including a reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, ptal
src/Workspaces/CSharp/Portable/Recommendations/CSharpRecommendationServiceRunner.cs
Outdated
Show resolved
Hide resolved
// Methods, properties, events, non-constant fields etc. are excluded since they are not constant expressions | ||
bool FilterMember(ISymbol symbol) | ||
{ | ||
return symbol is INamespaceOrTypeSymbol or IFieldSymbol { IsConst: true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about a constant local? can you add a test for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Local symbols are not contained within a type or namespace, so we will never encounter those through the filtering. However, we should have tests to make sure they are not overlooked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests showing the behavior in locals
Done with pass. looking good. |
Thanks! |
Fixes #75350
After an offline conversation with @CyrusNajmabadi, this PR only addresses the IDE suggestions, without changing the behavior of binding the symbol, or the parsed syntax. We simply reinterpret the non-const symbol as a type and suggest off of the type symbol.